/* *
 * AD Script for Oneway
 * @author: lethanhquang910@gmail.com
 * */

$(document).ready(function(){
    
    //Init tooltip
    $('#list_cm span[tooltip]').each(function()
   {
      $(this).qtip({
         content: $(this).attr('tooltip'), // Use the tooltip attribute of the element for the content
         position: {
             target: 'mouse'
         },
         style: { 
              padding: 3,
              color: '#FFFFFF',
              background: '#505050',
              textAlign: 'center',
              tip: 'topLeft',
              name: 'dark',
              border: {
                  width: 0,
                  radius: 5,
                  color: '#505050'
              }
        }
      });
   });
    
    //Update comment
    $('input[type=checkbox].verify_box').click(function(){
        var $this = $(this);
        var cm_id = $this.val();
        var status = $this.attr('checked');
        var total_cm = $('#total_cm').html();
        
        if (cm_id < 0)
        {
            return false;
        }
        
        if(status == true){status = 1;}else{status = 0;}
        
        $.ajax({
            type: 'POST',
            url: config.siteUrl + '/comment/updateCommentStatus',
            data:{cm_id:cm_id, status:status},
            dataType: 'json',
            success: function(result)
            {
                if(result == 1)
                {
                    //Hide comment
                    $('#cm_'+cm_id).fadeOut();
                    
                    //Update total
                    $('#total_cm').html(total_cm-1);
                }
            }
        });
    })
})


